<template>
  <a-modal
    :title="title"
    :width="width"
    :visible="visible"
    :confirm-loading="false"
    @ok="handleCancel"
    @cancel="handleCancel"
    cancelText="关闭"
  >
  <a-card :bordered="false">

    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange">
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无此图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="图片不存在" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无此文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="uploadFile(text)">
            下载
          </a-button>
        </template>
        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">查看详情</a>
        </span>
      </a-table>
    </div>
    <processing-modal1 ref="modalForm" @ok="modalFormOk"></processing-modal1>
  </a-card>
  </a-modal>
</template>

<script>

  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import JDictSelectTag from '@/components/dict/JDictSelectTag.vue'
  import {initDictOptions, filterMultiDictText} from '@/components/dict/JDictSelectUtil'
  import ProcessingModal1 from "./modules/ProcessingModal1";
  export default {
    name: "ProcessingListModal",
    mixins:[JeecgListMixin],
    components: {
        ProcessingModal1,
      JDictSelectTag,
    },
    data () {

      return {
          title:"审批历史-进行中",
          width:800,
          visible: false,
          queryParam: {
              processId:'3',
              approvalProcessType: '0'
          },
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          /*{
            title:'流程id',
            align:"center",
            dataIndex: 'processId'
          },*/
         /* {
              // 0_贫困户贷款，1_企业贷款，2_带贫企业认定，3_带贫合作社认定
            title:'流程类别',
            align:"center",
            dataIndex: 'approvalProcessType',
            customRender:(text)=>{
              if(!text){
                return ''
              }else{
                return filterMultiDictText(this.dictOptions['approvalProcessType'], text+"")
              }
            }
          },*/
            {
                title:'流程步骤',
                align:"center",
                dataIndex: 'approvalProcessCode',
                customRender:(text)=>{
                    if(!text){
                        return ''
                    }else{
                        return filterMultiDictText(this.dictOptions['currentStatusPkh'], text+"")
                    }
                }
            },
            {
                title:'受理人',
                align:"center",
                dataIndex: 'operator'
            },
          {
            title:'受理日期',
            align:"center",
            dataIndex: 'approvalProcessDate',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'回复内容',
            align:"center",
            dataIndex: 'replyContent'
          },
         /* {
            title:'相关资料',
            align:"center",
            dataIndex: 'information',
            scopedSlots: {customRender: 'fileSlot'}
          },*/
          {
              // 0_通过，1_拒绝
            title:'状态',
            align:"center",
            dataIndex: 'state',
            customRender:(text)=>{
              if(!text){
                return ''
              }else{
                return filterMultiDictText(this.dictOptions['processState'], text+"")
              }
            }
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            scopedSlots: { customRender: 'action' },
          }
        ],
        url: {
          list: "/loanmanagement/processing/list",
          delete: "/loanmanagement/processing/delete",
          deleteBatch: "/loanmanagement/processing/deleteBatch",
          exportXlsUrl: "/loanmanagement/processing/exportXls",
          importExcelUrl: "loanmanagement/processing/importExcel",
        },
        dictOptions:{
         approvalProcessType:[],
         state:[],
        } 
      }
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      }
    },
    methods: {
      initDictConfig(){
        initDictOptions('approval_process_type').then((res) => {
          if (res.success) {
            this.$set(this.dictOptions, 'approvalProcessType', res.result)
          }
        })
          initDictOptions('current_status_pkh').then((res) => {
              if (res.success) {
                  this.$set(this.dictOptions, 'currentStatusPkh', res.result)
              }
          })
        initDictOptions('process_state').then((res) => {
          if (res.success) {
            this.$set(this.dictOptions, 'processState', res.result)
          }
        })
      },
        showGoodsGallery1(record) {
            this.queryParam.processId=record.id
            this.queryParam.approvalProcessType = '0'
            this.loadData(1);
            this.visible = true
        },
        handleCancel(){
            this.visible=false;
        }
        ,
        handleEdit: function (record) {
            this.$refs.modalForm.edit(record);
            this.$refs.modalForm.title = "查看详情";
            this.$refs.modalForm.disableSubmit = false;
        }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>